package com.ljh.mall.product.web;

import com.alibaba.fastjson.JSON;
import com.ljh.mall.product.service.SkuInfoService;
import com.ljh.mall.product.vo.SpuItemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

/**
 * @author ：刘剑鸿
 * @date ：Created in 2023/3/26 18:22
 * @description： 商品详情的控制器
 * @modified By：
 * @version: $
 */
@Controller
public class ItemController {
    @Autowired
    SkuInfoService skuInfoService;

    @GetMapping("/{skuId}.html")
    public String item(@PathVariable Long skuId, Model model) throws ExecutionException, InterruptedException {
        SpuItemVO itemVo = skuInfoService.items(skuId);
        System.out.println(JSON.toJSONString(itemVo));
        model.addAttribute("item",itemVo);
        return "item";
    }
}
